import React, { Component } from 'react'
import { Route, Redirect, Switch } from "react-router-dom";
import Login from "./views/Login";
import Admin from "./Layouts/Index";
import Hoc from "./views/Admin/Hoc";
import './App.css';
import "antd/dist/antd.css"
import myContext from "./utils/myContext";
import NotFound from './views/NotFound';

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      name: "柴正盼",
      age: 18,
      changeAge: this.changeAge
    }
  }

  changeAge = (inc) => {
    this.setState({
      age: this.state.age + inc
    });
  }

  render() {
    return (
      <myContext.Provider value={this.state}>
        <Switch>
          <Redirect exact={true} from="/" to="/Admin" ></Redirect>
          <Route path="/Login" component={Login}></Route>
          <Route  path="/Admin" component={Admin}></Route>
          <Route component={NotFound}></Route>
        </Switch>
      </myContext.Provider>
    )
  }
}


export default App;
